package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.db.Analysis;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface AnalysisMapper extends BaseMapper<Analysis> {

    //所有注册用户的和
    @Select("SELECT sum(num_registered) FROM tb_analysis")
    Integer getCountNumRegistered();
    //求两时间直接的活跃用户数量
    //方案二Select sum(num_registered) FROM tb_analysis WHERE record_date BETWEEN DATE_SUB(#{today},INTERVAL #{num} DAY) AND #{today}
    @Select("SELECT sum(num_active) FROM tb_analysis WHERE record_date BETWEEN #{lastMonth} AND #{today}")
    Integer getCountNumActice(String lastMonth,String today);
    //获取参数日期的注册用户
    @Select("Select num_registered FROM tb_analysis where record_date = #{day}")
    Integer getNewUsers(String day);
    //获取参数日期的登录次数
    @Select("Select num_login FROM tb_analysis where record_date = #{day}")
    Integer getLoginTimes(String day);
    //获取参数日期的活跃用户数
    @Select("Select num_active FROM tb_analysis where record_date = #{day}")
    Integer getActiveUsers(String today);
    //获取两个时间之间的所有analysis
    @Select("Select * FROM tb_analysis WHERE record_date BETWEEN #{lastday} AND #{today}")
    List<Analysis> getBetweenTime(String lastday , String today );
}
